package com.jhy.new2025.array;


/**
 * 求中心坐标
 */
public class PivotIndex {
    public int pivotIndex(int[] nums) {

        for (int i = 0; i <= nums.length - 1; i++) {
            int sumLeft = 0;
            int sumRight = 0;
            for (int j = 0; j < i; j++) {
                sumLeft += nums[j];
            }
            for (int j = i + 1; j <= nums.length - 1; j++) {
                sumRight += nums[j];
            }
            if (sumLeft == sumRight) {
                return i;
            }

        }

        return -1;
    }
}
